//
// Created by admin on 2024/12/4.
//

#ifndef AVM_RENDER_CURVEMESH_H
#define AVM_RENDER_CURVEMESH_H

#include "CurveSamples.h"
#include <memory>

/**
 * @brief 表示一条曲线的顶点模型。可用于OPENGL渲染。
 */
class CurveMesh {
public:
    CurveMesh(){};
    CurveMesh(const CurveSamples& left_curve, const CurveSamples& middle_curve, const CurveSamples& right_curve);
    virtual ~CurveMesh(){};

    virtual int build(const CurveSamples& middle_curve);
    std::shared_ptr<float> generate_vertex_buffer();
    std::shared_ptr<unsigned int> generate_index_buffer(int &size);

    CurveSamples test_get_left_curve(){ return m_left_curve;}
    CurveSamples test_get_right_curve(){ return m_right_curve;}

private:
    enum CurveSampleType {
        LEFT,
        MIDDLE,
        RIGHT
    };

    CurveSamples m_left_curve;
    CurveSamples m_middle_curve;
    CurveSamples m_right_curve;

    void internal_build_curve(const CurveSamples& middle_curve);
    int index_at_vertex_buffer(int sample_index, CurveSampleType sample_type);

    const float WIDTH_SCALE = 20.0f;
};


#endif //AVM_RENDER_CURVEMESH_H
